package org.lsms.servlet;

/**
 * servlet invoked when administrator modify the mail content
 * @author ZhanXueliang
 * 2010.9.15
 */

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lsms.dao.impl.DaoImpl;

public class modify_mail_content extends HttpServlet {

	
	public void destroy() {
		super.destroy(); 
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			
			String invite_reviewer = request.getParameter("invite_reviewer");
			String invite_member = request.getParameter("invite_member");
			String chair_assign_paper = request.getParameter("chair_assign_paper");
			String member_assign_paper = request.getParameter("member_assign_paper");
			String to_pass_paper = request.getParameter("to_pass_paper");
			String to_unpass_paper = request.getParameter("to_unpass_paper");
			String to_all = request.getParameter("to_all");
			
			DaoImpl impl = new DaoImpl();
			
			if(!impl.modify_mail_content(invite_reviewer, 1)){
				String info = "Problem occurs when modify the content of invite " +
						"reviewer mail!Try again later!";
				response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
				return;
			}
			
			if(!impl.modify_mail_content(invite_member, 2)){
				String info = "Problem occurs when modify the content of invite " +
						"PC member mail!Try again later!";
				response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
				return;
			}
			
			if(!impl.modify_mail_content(chair_assign_paper, 3)){
				String info = "Problem occurs when modify the content of chair " +
						"assign paper mail!Try again later!";
				response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
				return;
			}
	
			if(!impl.modify_mail_content(member_assign_paper, 4)){
				String info = "Problem occurs when modify the content of member " +
						"assign paper mail!Try again later!";
				response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
				return;
			}
			
			if(!impl.modify_mail_content(to_pass_paper, 5)){
				String info = "Problem occurs when modify the content of mail " +
						"send to pass paper!Try again later!";
				response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
				return;
			}
			
			if(!impl.modify_mail_content(to_unpass_paper, 6)){
				String info = "Problem occurs when modify the content of mail " +
						"send to unpass paper!Try again later!";
				response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
				return;
			}
			
			if(!impl.modify_mail_content(to_all, 7)){
				String info = "Problem occurs when modify the content of mail " +
						"send to all paper!Try again later!";
				response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
				return;
			}
			
			String info = "Mail content update succeed!";
			response.sendRedirect("admin/admin_show_info.jsp?admin_info="+info);
	}

	
	public void init() throws ServletException {
		// Put your code here
	}

}
